import { createRouter, createWebHashHistory, createWebHistory } from "vue-router";
// 普通引入
// import Home from "../views/Home/index.vue";
// import About from "../views/About/index.vue";

/*
  路由懒加载：

  import语法动态引入：
    1. 代码分割：
      将引入的组件代码，单独打包成一个js文件
    2. 按需加载
      需要使用时，才会加载这个文件
*/
const Home = () => {
  return import("../views/Home/index.vue");
};
const About = () => import("../views/About/index.vue");

export default createRouter({
  // 路由模式
  history: createWebHistory(),
  routes: [
    {
      path: "/home",
      name: "Home",
      meta: { title: "Home" },
      component: Home,
    },
    {
      path: "/about",
      name: "About",
      meta: { title: "About" },
      component: About,
    },
    {
      path: "/",
      redirect: "/home",
    },
  ],
});
